]> dgit.raspbian.org Git - grub2.git/commit
efi/chainloader: set the loaded image device path when it is missing
authorMate Kukri <mate.kukri@canonical.com>
Tue, 23 Jun 2026 14:19:15 +0000 (15:19 +0100)
committerSteve McIntyre <93sam@debian.org>
Wed, 23 Sep 2026 20:39:45 +0000 (21:39 +0100)
commit8371c2628de3d92168aced20ecfd02d116ced5d6
tree65826732db8be6772412d79bf6e3ec16ad246acb
parent0b09dacdb59f9b3a14f0f13a4d3645476741d092
efi/chainloader: set the loaded image device path when it is missing

Under Secure Boot grub verifies images in its verifier framework
(grub-core/kern/efi/sb.c). The verifier loads the image through the shim image
loader protocol, passing only the image buffer and a NULL device path, because
the device path is not available at that point. The verified image handle,
which the chainloader reuses, is therefore left with no device path: both
loaded_image->file_path and the LOADED_IMAGE_DEVICE_PATH protocol are NULL.

This is a consequence of grub loading the image inside the verifier, separate
from where the device path is built. Images that walk their own device path
then loop forever looking for the end node. Windows' bootmgfw.efi does this and
the machine hangs.

The chainloader already builds the file's device path. Also point
loaded_image->file_path and the LOADED_IMAGE_DEVICE_PATH protocol at it. The
image's loader owns those fields and frees them with the EFI pool allocator, so
save the originals and restore them before unloading the image if it returns.

Signed-off-by: Mate Kukri <mate.kukri@canonical.com>
Gbp-Pq: Topic upstream
Gbp-Pq: Name efi-chainloader-set-loaded-image-device-path.patch
grub-core/loader/efi/chainloader.c